package com.bkq.cb;
import com.bkq.cb.R;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;


public class MainScreen extends Activity {
	private Button back,exit,add,report,contact,exchangeRate,cashbook;
	int request_Code = 1;
	String idUser;
	String value,temp;
	TextView name;
	  public void onCreate(Bundle savedInstanceState) {
			 super.onCreate(savedInstanceState);
		     setContentView(R.layout.main_menu);
		     back = (Button)findViewById(R.id.backIma_mainMenu);
		    name = (TextView)findViewById(R.id.user_MainMenu);
		     exit = (Button)findViewById(R.id.exitIma_mainMenu);
		     add = (Button)findViewById(R.id.addTransactionIma_mainMenu);
		     report = (Button)findViewById(R.id.reportIma_mainMenu);
		     contact = (Button)findViewById(R.id.contactIma_mainMenu);
		     cashbook = (Button)findViewById(R.id.cashbookIma_mainMenu);
		     exchangeRate = (Button)findViewById(R.id.rateCurrencyIma_mainMenu);
		  
		     /**
		      * Lấy idUser
		      * String idUser = extras.getString("idUser").toString();
		      */

		   
		    Bundle extras = getIntent().getExtras();
			if (extras != null) {
				value = extras.getString("nameUser");
			    idUser = extras.getString("idUser").toString();
				
			}
			temp = name.getText().toString()+ value;
		name.setText(temp);
		       back.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					
					startActivity(new Intent(MainScreen.this,Login.class));

				}
			});
		     report.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent i = new Intent(MainScreen.this,DayReportScreen.class);
					i.putExtra("idUser", idUser);
					i.putExtra("nameUser", value);
					startActivity(i);
				}
			})  ;
		    cashbook.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent i = new Intent(MainScreen.this,CashBookScreen.class);
					i.putExtra("idUser", idUser);
					i.putExtra("nameUser", value);
					i.putExtra("check", "0");
					i.putExtra("day", "1/1/2011");
					i.putExtra("dayTo", "31/12/2011");
					startActivity(i);
				}
			})   ;
		    add.setOnClickListener(new View.OnClickListener() {
					
					@Override
					public void onClick(View v) {
						
						Intent i = new Intent(MainScreen.this,AddScreen.class);
						i.putExtra("idUser", idUser);
						startActivity(i);

					}
		    });
		     exit.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					//System.runFinalizersOnExit(true);
					System.exit(0);
					
				}
			});
		     exchangeRate.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					startActivity(new Intent(MainScreen.this,ExchangeRateScreen.class));
				}
			});
		     
		     contact.setOnClickListener(new View.OnClickListener() {
					
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						startActivity(new Intent(MainScreen.this,ReportScreen.class));
						

					}
				});
	  }
	 
		
		
}
